/*
               File: ModReg
        Description: Modificar Registro
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 17:21:38.77
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class pmodreg extends GXProcedure
{
   public pmodreg( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( pmodreg.class ), "" );
   }

   public pmodreg( int remoteHandle ,
                   ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( int aP0 ,
                        String aP1 ,
                        String aP2 ,
                        String aP3 ,
                        String aP4 ,
                        String aP5 ,
                        String aP6 ,
                        byte[] aP7 )
   {
      execute_int(aP0, aP1, aP2, aP3, aP4, aP5, aP6, aP7);
   }

   private void execute_int( int aP0 ,
                             String aP1 ,
                             String aP2 ,
                             String aP3 ,
                             String aP4 ,
                             String aP5 ,
                             String aP6 ,
                             byte[] aP7 )
   {
      pmodreg.this.AV8Codigo = aP0;
      pmodreg.this.AV14Codaux = aP1;
      pmodreg.this.AV11Descri = aP2;
      pmodreg.this.AV15Tipo = aP3;
      pmodreg.this.AV12Estado = aP4;
      pmodreg.this.AV13Usuari = aP5;
      pmodreg.this.AV10Tabla = aP6;
      pmodreg.this.aP7 = aP7;
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      if ( ( GXutil.strcmp(AV10Tabla, "MMCMB10") == 0 ) )
      {
         AV9Pout = 0 ;
         /* Using cursor P00132 */
         pr_default.execute(0, new Object[] {new Integer(AV8Codigo)});
         while ( (pr_default.getStatus(0) != 101) )
         {
            A523CmbCod = P00132_A523CmbCod[0] ;
            A578CmbNom = P00132_A578CmbNom[0] ;
            A579CmbEst = P00132_A579CmbEst[0] ;
            A585CmbUUM = P00132_A585CmbUUM[0] ;
            A583CmbFUM = P00132_A583CmbFUM[0] ;
            A584CmbHUM = P00132_A584CmbHUM[0] ;
            A578CmbNom = GXutil.upper( GXutil.trim( AV11Descri)) ;
            A579CmbEst = AV12Estado ;
            A585CmbUUM = AV13Usuari ;
            A583CmbFUM = GXutil.serverDate( context, remoteHandle, "DEFAULT") ;
            A584CmbHUM = GXutil.serverTime( context, remoteHandle, "DEFAULT") ;
            AV9Pout = (byte)(1) ;
            /* Using cursor P00133 */
            pr_default.execute(1, new Object[] {A578CmbNom, A579CmbEst, A585CmbUUM, A583CmbFUM, A584CmbHUM, new Integer(A523CmbCod)});
            /* Check if program is canceled. */
            /* Exiting from a For First loop. */
            if (true) break;
         }
         pr_default.close(0);
      }
      else if ( ( GXutil.strcmp(AV10Tabla, "MMTAU10") == 0 ) )
      {
         AV9Pout = 0 ;
         /* Using cursor P00134 */
         pr_default.execute(2, new Object[] {new Integer(AV8Codigo)});
         while ( (pr_default.getStatus(2) != 101) )
         {
            A376TipAut = P00134_A376TipAut[0] ;
            A377TipAut = P00134_A377TipAut[0] ;
            A378TipAut = P00134_A378TipAut[0] ;
            A384TipAut = P00134_A384TipAut[0] ;
            A382TipAut = P00134_A382TipAut[0] ;
            A383TipAut = P00134_A383TipAut[0] ;
            A377TipAut = GXutil.upper( GXutil.trim( AV11Descri)) ;
            A378TipAut = AV12Estado ;
            A384TipAut = AV13Usuari ;
            A382TipAut = GXutil.serverDate( context, remoteHandle, "DEFAULT") ;
            A383TipAut = GXutil.serverTime( context, remoteHandle, "DEFAULT") ;
            AV9Pout = (byte)(1) ;
            /* Using cursor P00135 */
            pr_default.execute(3, new Object[] {A377TipAut, A378TipAut, A384TipAut, A382TipAut, A383TipAut, new Byte(A376TipAut)});
            /* Check if program is canceled. */
            /* Exiting from a For First loop. */
            if (true) break;
         }
         pr_default.close(2);
      }
      else if ( ( GXutil.strcmp(AV10Tabla, "MMMRC10") == 0 ) )
      {
         AV9Pout = 0 ;
         /* Using cursor P00136 */
         pr_default.execute(4, new Object[] {AV14Codaux});
         while ( (pr_default.getStatus(4) != 101) )
         {
            A189MarCod = P00136_A189MarCod[0] ;
            A357MarNom = P00136_A357MarNom[0] ;
            A358MarTip = P00136_A358MarTip[0] ;
            A190MarEst = P00136_A190MarEst[0] ;
            A364MarUUM = P00136_A364MarUUM[0] ;
            A362MarFUM = P00136_A362MarFUM[0] ;
            A363MarHUM = P00136_A363MarHUM[0] ;
            if ( ( GXutil.strcmp(A189MarCod, GXutil.trim( AV14Codaux)) == 0 ) )
            {
               A357MarNom = GXutil.upper( GXutil.trim( AV11Descri)) ;
               A358MarTip = AV15Tipo ;
               A190MarEst = AV12Estado ;
               A364MarUUM = AV13Usuari ;
               A362MarFUM = GXutil.serverDate( context, remoteHandle, "DEFAULT") ;
               A363MarHUM = GXutil.serverTime( context, remoteHandle, "DEFAULT") ;
               AV9Pout = (byte)(1) ;
               /* Using cursor P00137 */
               pr_default.execute(5, new Object[] {A357MarNom, A358MarTip, A190MarEst, A364MarUUM, A362MarFUM, A363MarHUM, A189MarCod});
            }
            /* Check if program is canceled. */
            pr_default.readNext(4);
         }
         pr_default.close(4);
      }
      cleanup();
   }

   protected void cleanup( )
   {
      this.aP7[0] = pmodreg.this.AV9Pout;
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      AV9Pout = 0 ;
      P00132_A523CmbCod = new int[1] ;
      P00132_A578CmbNom = new String[] {""} ;
      P00132_A579CmbEst = new String[] {""} ;
      P00132_A585CmbUUM = new String[] {""} ;
      P00132_A583CmbFUM = new java.util.Date[] {GXutil.nullDate()} ;
      P00132_A584CmbHUM = new String[] {""} ;
      A523CmbCod = 0 ;
      A578CmbNom = "" ;
      A579CmbEst = "" ;
      A585CmbUUM = "" ;
      A583CmbFUM = GXutil.nullDate() ;
      A584CmbHUM = "" ;
      P00134_A376TipAut = new byte[1] ;
      P00134_A377TipAut = new String[] {""} ;
      P00134_A378TipAut = new String[] {""} ;
      P00134_A384TipAut = new String[] {""} ;
      P00134_A382TipAut = new java.util.Date[] {GXutil.nullDate()} ;
      P00134_A383TipAut = new String[] {""} ;
      A376TipAut = 0 ;
      A377TipAut = "" ;
      A378TipAut = "" ;
      A384TipAut = "" ;
      A382TipAut = GXutil.nullDate() ;
      A383TipAut = "" ;
      P00136_A189MarCod = new String[] {""} ;
      P00136_A357MarNom = new String[] {""} ;
      P00136_A358MarTip = new String[] {""} ;
      P00136_A190MarEst = new String[] {""} ;
      P00136_A364MarUUM = new String[] {""} ;
      P00136_A362MarFUM = new java.util.Date[] {GXutil.nullDate()} ;
      P00136_A363MarHUM = new String[] {""} ;
      A189MarCod = "" ;
      A357MarNom = "" ;
      A358MarTip = "" ;
      A190MarEst = "" ;
      A364MarUUM = "" ;
      A362MarFUM = GXutil.nullDate() ;
      A363MarHUM = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new pmodreg__default(),
         new Object[] {
             new Object[] {
            P00132_A523CmbCod, P00132_A578CmbNom, P00132_A579CmbEst, P00132_A585CmbUUM, P00132_A583CmbFUM, P00132_A584CmbHUM
            }
            , new Object[] {
            }
            , new Object[] {
            P00134_A376TipAut, P00134_A377TipAut, P00134_A378TipAut, P00134_A384TipAut, P00134_A382TipAut, P00134_A383TipAut
            }
            , new Object[] {
            }
            , new Object[] {
            P00136_A189MarCod, P00136_A357MarNom, P00136_A358MarTip, P00136_A190MarEst, P00136_A364MarUUM, P00136_A362MarFUM, P00136_A363MarHUM
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private byte AV9Pout ;
   private byte A376TipAut ;
   private short Gx_err ;
   private int AV8Codigo ;
   private int A523CmbCod ;
   private String AV14Codaux ;
   private String AV11Descri ;
   private String AV15Tipo ;
   private String AV12Estado ;
   private String AV13Usuari ;
   private String AV10Tabla ;
   private String A578CmbNom ;
   private String A579CmbEst ;
   private String A585CmbUUM ;
   private String A584CmbHUM ;
   private String A377TipAut ;
   private String A378TipAut ;
   private String A384TipAut ;
   private String A383TipAut ;
   private String A189MarCod ;
   private String A357MarNom ;
   private String A358MarTip ;
   private String A190MarEst ;
   private String A364MarUUM ;
   private String A363MarHUM ;
   private java.util.Date A583CmbFUM ;
   private java.util.Date A382TipAut ;
   private java.util.Date A362MarFUM ;
   private byte[] aP7 ;
   private IDataStoreProvider pr_default ;
   private int[] P00132_A523CmbCod ;
   private String[] P00132_A578CmbNom ;
   private String[] P00132_A579CmbEst ;
   private String[] P00132_A585CmbUUM ;
   private java.util.Date[] P00132_A583CmbFUM ;
   private String[] P00132_A584CmbHUM ;
   private byte[] P00134_A376TipAut ;
   private String[] P00134_A377TipAut ;
   private String[] P00134_A378TipAut ;
   private String[] P00134_A384TipAut ;
   private java.util.Date[] P00134_A382TipAut ;
   private String[] P00134_A383TipAut ;
   private String[] P00136_A189MarCod ;
   private String[] P00136_A357MarNom ;
   private String[] P00136_A358MarTip ;
   private String[] P00136_A190MarEst ;
   private String[] P00136_A364MarUUM ;
   private java.util.Date[] P00136_A362MarFUM ;
   private String[] P00136_A363MarHUM ;
}

final class pmodreg__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("P00132", "SELECT [CmbCod], [CmbNom], [CmbEst], [CmbUUM], [CmbFUM], [CmbHUM] FROM [MMCMB10] WITH (UPDLOCK) WHERE [CmbCod] = ? ",true, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,true )
         ,new UpdateCursor("P00133", "UPDATE [MMCMB10] SET [CmbNom]=?, [CmbEst]=?, [CmbUUM]=?, [CmbFUM]=?, [CmbHUM]=?  WHERE [CmbCod] = ?", GX_NOMASK + GX_MASKLOOPLOCK)
         ,new ForEachCursor("P00134", "SELECT [TipAutCod], [TipAutNom], [TipAutEst], [TipAutUUM], [TipAutFUM], [TipAutHUM] FROM [MMTAU10] WITH (UPDLOCK) WHERE [TipAutCod] = ? ",true, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,true )
         ,new UpdateCursor("P00135", "UPDATE [MMTAU10] SET [TipAutNom]=?, [TipAutEst]=?, [TipAutUUM]=?, [TipAutFUM]=?, [TipAutHUM]=?  WHERE [TipAutCod] = ?", GX_NOMASK + GX_MASKLOOPLOCK)
         ,new ForEachCursor("P00136", "SELECT [MarCod], [MarNom], [MarTip], [MarEst], [MarUUM], [MarFUM], [MarHUM] FROM [MMMRC10] WITH (UPDLOCK) WHERE [MarCod] = RTRIM(?) ORDER BY [MarCod] ",true, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("P00137", "UPDATE [MMMRC10] SET [MarNom]=?, [MarTip]=?, [MarEst]=?, [MarUUM]=?, [MarFUM]=?, [MarHUM]=?  WHERE [MarCod] = ?", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((int[]) buf[0])[0] = rslt.getInt(1) ;
               ((String[]) buf[1])[0] = rslt.getString(2, 50) ;
               ((String[]) buf[2])[0] = rslt.getString(3, 1) ;
               ((String[]) buf[3])[0] = rslt.getString(4, 10) ;
               ((java.util.Date[]) buf[4])[0] = rslt.getGXDate(5) ;
               ((String[]) buf[5])[0] = rslt.getString(6, 8) ;
               break;
            case 2 :
               ((byte[]) buf[0])[0] = rslt.getByte(1) ;
               ((String[]) buf[1])[0] = rslt.getString(2, 20) ;
               ((String[]) buf[2])[0] = rslt.getString(3, 1) ;
               ((String[]) buf[3])[0] = rslt.getString(4, 10) ;
               ((java.util.Date[]) buf[4])[0] = rslt.getGXDate(5) ;
               ((String[]) buf[5])[0] = rslt.getString(6, 8) ;
               break;
            case 4 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((String[]) buf[1])[0] = rslt.getString(2, 20) ;
               ((String[]) buf[2])[0] = rslt.getString(3, 1) ;
               ((String[]) buf[3])[0] = rslt.getString(4, 1) ;
               ((String[]) buf[4])[0] = rslt.getString(5, 10) ;
               ((java.util.Date[]) buf[5])[0] = rslt.getGXDate(6) ;
               ((String[]) buf[6])[0] = rslt.getString(7, 8) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               stmt.setInt(1, ((Integer) parms[0]).intValue());
               break;
            case 1 :
               stmt.setString(1, (String)parms[0], 50);
               stmt.setString(2, (String)parms[1], 1);
               stmt.setString(3, (String)parms[2], 10);
               stmt.setDate(4, (java.util.Date)parms[3]);
               stmt.setString(5, (String)parms[4], 8);
               stmt.setInt(6, ((Integer) parms[5]).intValue());
               break;
            case 2 :
               stmt.setInt(1, ((Integer) parms[0]).intValue());
               break;
            case 3 :
               stmt.setString(1, (String)parms[0], 20);
               stmt.setString(2, (String)parms[1], 1);
               stmt.setString(3, (String)parms[2], 10);
               stmt.setDate(4, (java.util.Date)parms[3]);
               stmt.setString(5, (String)parms[4], 8);
               stmt.setByte(6, ((Byte) parms[5]).byteValue());
               break;
            case 4 :
               stmt.setString(1, (String)parms[0], 10);
               break;
            case 5 :
               stmt.setString(1, (String)parms[0], 20);
               stmt.setString(2, (String)parms[1], 1);
               stmt.setString(3, (String)parms[2], 1);
               stmt.setString(4, (String)parms[3], 10);
               stmt.setDate(5, (java.util.Date)parms[4]);
               stmt.setString(6, (String)parms[5], 8);
               stmt.setString(7, (String)parms[6], 10);
               break;
      }
   }

}

